import time
st = time.clock()

def is_emphasise(x):
    '''判断是否是回文数'''
    return True if str(x)==str(x)[::-1] else False

result = 0 #记录找到的总数
for i in range(1,10001):
    st_num = i
    mid_nums = []
    n = 0
    while n<50:
        is_break = False
        for_reverse = st_num
        reverse_value = int(str(for_reverse)[::-1])
        mid_nums.append(st_num)
        mid_nums.append(reverse_value)
        add_res = st_num + reverse_value
        if is_emphasise(add_res):
            is_break = True
            break
        else:
            st_num = add_res
            n += 1
    if n==50 and not is_break:
        result += 1

print(result)
print(time.clock()-st)